import * as actionTypes from "./actionTypes";
import axios from 'axios';
export const changeAllList = (result) => ({
    type: actionTypes.getAllIndex,
    result,
})
export const changeUlList = (result) => ({
    type: actionTypes.getUlList,
    result,
})
export const setUlListType = (data) => ({
    type: actionTypes.setUlListType,
    data
})
//页面初始化
export const getAllList = () => {
    return (dispatch) => {
        axios.all([axios.post("/homeList.json"), axios.get("/menuArr.json")])
            .then(axios.spread(function (ulDate, menuArr) {
                console.log(1121, ulDate, menuArr)
                let data1=JSON.parse(JSON.stringify(ulDate.data))
                let ulDate1 = data1.map(i => {
                    i.object.data.title = "111"
                    return i
                })
                console.log('******ulDate1*',ulDate1)
                let result = {
                    ulDate: ulDate.data,
                    ulDate1,
                    ulDate2: ulDate.data,
                    menuArr: menuArr.data
                }
                dispatch(changeAllList(result))
            }))
    }
}
export const getList = (i) => {
    console.log('tye(((', i)
    return (dispatch) => {
        axios.post("/homeList.json").then(res => {
            if (res.status === 200) {
                let result = {}
                if (i === 1) {
                    result.data = res.data.map(i => {
                        i.object.data.title = "111"
                        return i
                    });
                }
                result.data = res.data
                result.type = i;
                dispatch(changeUlList(result))
            }
        })
    }
}
